package hk.m4s.lr.repair.test.ui.adapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.NoticeModel;
import hk.m4s.lr.repair.test.ui.user.UserNoticeActivity;

/**
 * 
 * @author
 * 
 */
public class UserNoticeAdapter extends BaseAdapter {
	private UserNoticeActivity context;
	public List<NoticeModel> items;
	public UserNoticeAdapter(UserNoticeActivity context,
			List<NoticeModel> items) {
		this.context = context;
		this.items = items;
	}

	public int getCount() {
		return items.size();
	}

	public Object getItem(int position) {
		return getView(position, null, null);
	}

	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder=null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.list_item_user_notice, null);
			 holder = new ViewHolder();
			holder.tvTitle = (TextView) convertView
					.findViewById(R.id.notice_title);
			holder.tvDay = (TextView) convertView.findViewById(R.id.notice_day);
			holder.notice_detil = (TextView) convertView
					.findViewById(R.id.notice_detil);
			holder.show_tips=(ImageView)convertView.findViewById(R.id.show_tips_notice);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (position >= items.size()) {
			return convertView;
		}
		final NoticeModel item = items.get(position);
		// 标题

		holder.tvTitle.setText("系统消息");
		// 年月日

		holder.tvDay.setText(item.getSubtime());
		// 小时分钟
        if(item.getReadTime().equals("")){
			holder.show_tips.setVisibility(View.VISIBLE);
		}else{
			holder.show_tips.setVisibility(View.GONE);
		}
		holder.notice_detil.setText(item.getTitle());

		return convertView;
	}

	private class ViewHolder {
		TextView tvTitle;
		TextView tvDay;
		TextView notice_detil;
		ImageView show_tips;
	}
}
